package com.service.imple.admin;

import com.dao.NewsCatalogMapper;
import com.entity.GoodsCatalog;
import com.entity.NewsCatalog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.admin.NewsCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class NewsCatalogServiceImple implements NewsCatalogService {

    @Autowired
    private NewsCatalogMapper newsCatalogMapper;


    @Override
    public PageInfo<NewsCatalog> selectByPage(Map<String, Object> param) {
        int pageNum=Integer.parseInt(param.get("pageNum").toString());
        PageHelper.startPage(pageNum,6);
        List<NewsCatalog> list = newsCatalogMapper.SelectPage(param);
        PageInfo<NewsCatalog> info =new PageInfo<>(list);
        return info;
    }

    @Override
    public List<NewsCatalog> select(Map map) {
        return newsCatalogMapper.SelectPage(map);
    }

    @Override
    public int insert(NewsCatalog newsCatalog) {
        return newsCatalogMapper.insert(newsCatalog);
    }

    @Override
    public int update(NewsCatalog newsCatalog) {
        return newsCatalogMapper.updateByPrimaryKey(newsCatalog);
    }

    @Override
    public int delete(int id) {
        return newsCatalogMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<NewsCatalog> SelectPage(Map map) {
        return null;
    }
}
